package com.junlinpro.utils;

import org.springframework.stereotype.Component;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class PcmInByteData {

    //线程安全的
	private Map<String, LinkedList<byte[]>> pcmData = new ConcurrentHashMap<>();

    public void removePcmData(String key) {
        pcmData.remove(key);
    }

    public void put(String key, byte[] data) {
        if (pcmData.get(key) != null) {
            pcmData.get(key).add(data);
        } else {
            LinkedList<byte[]> listData = new LinkedList<>();
            listData.add(data);
            pcmData.put(key, listData);
        }
    }

    public List<byte[]> get(String key) {
        if (pcmData.get(key) != null && pcmData.get(key).size() > 0) {
            return pcmData.get(key);
        } else {
            return null;
        }
    }

}
